<?php
namespace App\Seeder;
use App\Http\Common\MyUtils;
use App\Models\WyAreas;
use App\Models\WyPropertys;
use Illuminate\Support\Facades\DB;

/**
 * 新增小区的一些初始化数据，部门，管理职位等
 * Class AddPropertySeeder
 */
class AddAreaSeeder extends BaseSeeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $areaId = $this->data['wy_area_id'];// 小区id
        $wyArea = WyAreas::where('id',$areaId)->get()->first();//物业id
        $wyPropertyId = $wyArea->wy_property_id;
        $projectId = MyUtils::getSessionConfig('PROJECT_ID');
        // 报修分类
        $this->addRepairType($areaId,$projectId,0,'居家报修','上门服务',$wyPropertyId);
        $this->addRepairType($areaId,$projectId,0,'小区报修','上门服务',$wyPropertyId);
        $this->addRepairType($areaId,$projectId,0,'小区卫生','上门服务',$wyPropertyId);
        $this->addRepairType($areaId,$projectId,0,'小区绿化','上门服务',$wyPropertyId);
        $this->addRepairType($areaId,$projectId,0,'小区安全','上门服务',$wyPropertyId);
        // 投诉建议分类
        $this->addComplicationSuggestionType($areaId,$projectId,'','公共设备设施',1);
        $this->addComplicationSuggestionType($areaId,$projectId,'','物业管理服务',1);
        $this->addComplicationSuggestionType($areaId,$projectId,'','小区扰民',-1);
        $this->addComplicationSuggestionType($areaId,$projectId,'','小区安全',1);
        $this->addComplicationSuggestionType($areaId,$projectId,'','小区绿化卫生',1);
    }

    /**
     * 新增报修分类
     * @param $areaId
     * @param $projectId
     * @param $price
     * @param $name
     * @param $style
     * @param $wyPropertyId
     * @return int
     */
    public function addRepairType($areaId,$projectId,$price,$name,$style,$wyPropertyId){
        $repairsTypeId = DB::table('wy_repairs_type')->insertGetId([
            'wy_area_id' => $areaId,
            'name' => $name,
            'price' => $price,
            'style' => $style,
            'wy_property_id' => $wyPropertyId,
            'project_id' => $projectId,
        ]);
        return $repairsTypeId;
    }

    /**
     * 新增投诉建议分类
     * @param $areaId
     * @param $projectId
     * @param $type
     * @param $name
     * @param $classify
     * @return int
     */
    public function addComplicationSuggestionType($areaId,$projectId,$type,$name,$classify){
        $repairsTypeId = DB::table('wy_complaint_suggestions_type')->insertGetId([
            'wy_area_id' => $areaId,
            'name' => $name,
            'classify' => $classify,
            'project_id' => $projectId,
        ]);
        return $repairsTypeId;
    }

}
